﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _017
{
    class Program
    {
        static void Main(string[] args)
        {
            Rectangle oblong = new Rectangle();
            oblong.setWidth(3);
            oblong.setHeight(4);
            int area = oblong.getArea();
            int girth = oblong.getGirth();
            Console.WriteLine("长方形的面积为：{0}",area);
            Console.WriteLine("长方形的周长为：{0}",girth);
            Console.WriteLine(); 
            Console.ReadKey();
        }
    }
    //父类
    class Shape
    {
        protected int width, height;//只能在父类、子类中使用
        public void setWidth(int w)
        {
            width = w;
        }
        public void setHeight(int h)
        {
            height = h;
        }
    }
    //定义接口
    public interface Perimeter
    {
        int getGirth();
    }
    //子类
    class Rectangle : Shape,Perimeter 
    {
        public int getArea()
        {
            return width * height;
        }
        public int getGirth()
        {
            return (width + height) * 2;
        }
    }
}
